﻿using Grundy.CryptographicServices;
using Grundy.Key.RsaProvider;
using log4net;

namespace Grundy.Administration.Web
{
    public class Application
    {
        ILog _logger = log4net.LogManager.GetLogger(typeof(Application));

        private static Application _instance = new Application();

        protected Application()
        {
            EntitlementServerCryptographicServicesProvider =  CreateCryptographicServicesProviders(EntitlementServer_RsaProvider_Private.Key);
            ClientCryptographicServicesProvider =  CreateCryptographicServicesProviders(Client_RsaProvider_Public.Key);
            ServerCryptographicServicesProvider =  CreateCryptographicServicesProviders(Server_RsaProvider_Private.Key);
        }

        public virtual CryptographicServicesProvider ClientCryptographicServicesProvider { get; private set; }
        public virtual CryptographicServicesProvider ServerCryptographicServicesProvider { get; private set; }
        public virtual CryptographicServicesProvider EntitlementServerCryptographicServicesProvider { get; private set; }

        private CryptographicServicesProvider CreateCryptographicServicesProviders(string key)
        {
            return new RsaProvider(key);
        }

        public static Application Instance { get { return _instance; } }
    }
}